home *** CD-ROM | disk | FTP | other *** search
- PAGE 66,132
- SUBTTL AFT8087.LIB - Macros Library P.C. FORTRAN INTERFACING
- PAGE
- COMMENT &
- ---------------------------------------------------------------
-
- * * * A F T 8 0 8 7 . L I B * * *
-
- Version 1.0
-
- This Library of Macros enables a FORTRAN Programmer to use the
- 8087 N.D.P. by adjusting the Floating Point representation of
- REAL numbers (as used in FORTRAN or BASIC) to the 8087 format.
- It also allows adjusting results from the 8087 back into the
- FORTRAN/BASIC format.
-
- This library was written by
- Jean-Marc Belisle
- GEOSTAT SYSTEMS INC.
- 10403 W. Colfax Av. Suite 450
- Lakewood, Colorado 80215
- U.S.A.
-
- REVISIONS ----------------------------
-
-
- --------------------------------------
-
-
- This software is PUBLIC DOMAIN
- However Please leave the mention of
- The author's name ... just to set the record straight
-
- This library was contributed to
- The Denver Amateur Computer Society
- by Jean-Marc Belisle
- January 1983
-
- ---------------------------------------------------------------
- &
-
- ;
- ;---- -------------
- ; Macro AT8087 is used to transform a REAL number to the 8087 format
- ; Macro AF8087 is used to transform a REAL number from 8087 format
- ;
- ; They are used as follows
- ;
- ; AT8087 <Ptr to 2 most significant bytes of number> [,<A>]
- ; [,<B>]
- ; [,<C>]
- ; [,<D>]
- ; The Ptr. addresses the exponent byte and the sign byte
- ; If the first parameter is absent then it is assumed (but not
- ; checked) that the exponent and sign are kept in the register
- ; specified by the second operand.
- ;
- ; The optional second parameter is the first letter of
- ; an "X" register (AX,BX,CX,DX). If used, the macros assume
- ; that the exponent and sign bytes are already loaded in that
- ; register. If left blank, then register AX is used.
- ;
- ; ONE of the 2 parameters MUST be specified.
- ;
- ; example :
- ;
- ; Number dd 83200000R ;define 5.0 in FORTRAN/BASIC
- ; ;format
- ; ...
- ; AT8087 Number+2 ;will adjust Number to the 8087
- ; ;format using AX
- ; mov cx,word ptr number+2 ;get the exponent & sign in CX
- ; AF8087 Number+2,C ;will adjust Number from the
- ; ;8087 format to the FORTRAN one
- ; ;using register CX
- ; AT8087 ,C ;Adjust CX content to 8087
- ; ;format
- ;
- ;---- -------------
- ;
- AT8087 MACRO SREAL,R
- IFB <R>
- MOV AX,WORD PTR SREAL ;GET EXPONENT
- ATGEN7 SREAL,A
- ELSE
- ATGEN7 SREAL,R
- ENDIF
- ENDM
- ATGEN7 MACRO SREAL,R
- LOCAL ZERO
- ;;--- PERFORM EXPONENT ADJUST
- OR R&H,R&H ;TEST FOR ZERO
- JZ ZERO ;BYPASS ADJUST IF SO
- SUB R&H,2 ;DECREMENT E FOR BIAS DIFFERENCE
- SHL R&L,1 ;SIGN INTO CARRY
- RCR R&X,1 ;SIGN INTO REG. HIGH
- IFNB <SREAL>
- MOV WORD PTR SREAL,R&X ;BACK IN PLACE
- ENDIF
- ZERO:
- ENDM
- ;
- AF8087 MACRO SREAL,R
- IFB <R>
- MOV AX,WORD PTR SREAL ;GET EXPONENT
- AFGEN7 SREAL,A
- ELSE
- AFGEN7 SREAL,R
- ENDIF
- ENDM
- AFGEN7 MACRO SREAL,R
- LOCAL ZERO
- ;;--- PERFORM EXPONENT ADJUST
- OR R&X,R&X ;TEST FOR ZERO
- JZ ZERO ;BYPASS ADJUST IF SO
- SHL R&L,1 ;E0 INTO CARRY
- RCL R&H,1 ;E0 INTO REG. HIGH. SIGN INTO CARRY
- RCR R&L,1 ;SIGN INTO REG. LOW
- ADD R&H,2 ;INCREMENT E FOR BIAS DIFFERENCE
- IFNB <SREAL>
- MOV WORD PTR SREAL,R&X ;BACK IN PLACE
- ENDIF
- ZERO:
- ENDM
-